/**
 * Created by luojie on 2018/3/12.
 */
import '../../css/index.scss'
export default class Index extends React.PureComponent {
	constructor(props) {
		super(props);
		this.state = {
			scaleState:true
		};
		this.join = this.join.bind(this);
		this.watchMore = this.watchMore.bind(this);
	}
	componentDidMount() {	
		console.log(document.documentElement.clientHeight)
		console.log(this.refs.main.offsetHeight)
		var h = this.refs.main.offsetHeight
		if(document.documentElement.clientHeight>this.refs.main.offsetHeight){
            this.refs.main.style.height = document.documentElement.clientHeight+'px'
        }else{
            // this.refs.main.style.position = 'fixed'
            // this.refs.main.style.left = '0'
            // this.refs.main.style.right = '0'
            // this.refs.main.style.bottom = '0'
			// this.refs.main.style.top = '0'
			this.refs.main.style.height = h+'px'
        }
		// this.init();
		this.animation()
	}
	componentWillUnmount(){
		this.timer && clearInterval(this.timer);
	}
	animation() {
		let {scaleState} = this.state
		this.timer = setInterval(() => {
			if(scaleState){
				this.refs.join_btn.style.transform = 'scale(1.2)'
				this.refs.fei.style.transform = 'translateY(0.15rem)'
				scaleState = !scaleState
			}else{
				this.refs.join_btn.style.transform = 'scale(1)'
				this.refs.fei.style.transform = 'translateY(0)'
				scaleState = !scaleState
			}
			this.setState({scaleState})
		}, 1000)
	}
	init() {
		let heightY = document.getElementsByClassName('main')[0].offsetHeight
		let h = screen.height
		if (heightY < h) {
			heightY = h
		}
		document.getElementsByClassName('main')[0].style.height = heightY + 'px'
	}
	join() {
		this.props.history.push("/login")
	}
	watchMore(){
		this.props.history.push("/activityDetail");
	}
	render() {
		return (
			<div className="main" ref='main'>
				<div className="top_bg"></div>
				<div className="fei" ref="fei"></div>
				<div className="active_bg"></div>
				{/* <div className="company_name">
				</div> */}
				<div className="active_content">
					成为豆壳教育广场会员<br />
					尊享7700㎡学习空间<br />
					首购全年课程5折等7大特权
				</div>
				<div className="wathch_more" onClick = {this.watchMore}></div>
				<div className="join_active" onClick = {this.join} ref="join_btn"></div>
				<div className="bot_bg"></div>
			</div>
		)
	}
}